import 'dart:async';

import 'package:sonora/models/sj_block_list_item_data.dart';
import 'package:sonora/models/sj_broad_caster_data.dart';
import 'package:sonora/models/sj_broad_caster_response_data.dart';
import 'package:sonora/models/sj_friend_list_body.dart';
import 'package:sonora/models/sj_friend_list_item_data.dart';
import 'package:sonora/models/sj_good_search_item_data.dart';
import 'package:sonora/models/sj_login_response_data.dart';
import 'package:sonora/models/sj_recharge_create_data.dart';
import 'package:sonora/models/sj_response_data.dart';
import 'package:sonora/services/sj_api_home_service.dart';
import 'package:sonora/services/sj_api_mine_service.dart';
import 'package:sonora/utils/sj_storage_utils.dart';

class SjMineRepository {
  final SjApiMineService apiService;
  SjMineRepository(this.apiService);

  Future<List<SjBroadCasterData>?> getWallSearch() async {
    SjBroadCasterResponseData? responseData = await SjStorageUtils.getBroadCasterResponseData();
      if (responseData == null) {
        responseData = await apiService.getWallSearch(20, 1);
        SjStorageUtils.saveBroadCasterResponseData(responseData);
      }
      return responseData.data;
  }

    Future<SjResponseData> getUserInfo(String userId) async {
    SjResponseData response =
        await apiService.getUserInfo(userId);
    return response;
  }

  Future<List<SjGoodSearchItemData>> goodsSearch() async {
    final list = await apiService.goodsSearch();
    return list;
  }

  Future<SjResponseData> getOssPolicy() async {
    SjResponseData responseData = await apiService.getOssPolicy();
    return responseData;
  }

  Future<SjResponseData> updateAvatar(String avatarPath) async {
    return await apiService.updateAvatar(avatarPath);
  }

  Future<SjResponseData> globalLogout() async {
    SjResponseData responseData = await apiService.globalLogout();
    return responseData;
  }

  Future<SjResponseData> deleteAccount() async {
    SjResponseData responseData = await apiService.deleteAccount();
    return responseData;
  }

  Future<List<SjFriendListItemData>> friendList() async {
    List<SjFriendListItemData> list = await apiService.friendList();
    return list;
  }

  Future<List<SjBlockListItemData>> blockList() async {
    List<SjBlockListItemData> list = await apiService.blockList();
    return list;
  }

  FutureOr<SjResponseData> addFriend(String followUserId) async {
    return await apiService.addFriend(followUserId);
  }

  FutureOr<SjResponseData> unFriend(String followUserId) async {
    return await apiService.unFriend(followUserId);
  }

  FutureOr<SjResponseData> insertRecord(String? broadcasterId, String? complainCategory, String? complainSub) async {
    return await apiService.insertRecord(broadcasterId, complainCategory, complainSub);
  }

  FutureOr<SjResponseData> removeBlock(String blockUserId) async {
    return await apiService.removeBlock(blockUserId);
  }

  Future<SjResponseData> saveUserInfo(String? nickName, String? country, String? birthday) async {
    return apiService.saveUserInfo(nickName, country, birthday);
  }

  Future<SjResponseData> rechargeCreate(String goodsCode) async {
    return apiService.rechargeCreate(goodsCode);
  }

  Future<SjResponseData> rechargePayment(String orderNo, String payload, String transactionId) async {
    return apiService.rechargePayment(orderNo, payload, transactionId);
  }
}